package com.jim.jeecg.imvc2.business.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jim.jeecg.imvc2.business.form.LoginForm;
import com.jim.jeecg.imvc2.core.action.Action;
import com.jim.jeecg.imvc2.core.annotation.Controller;
import com.jim.jeecg.imvc2.core.annotation.Forward;
import com.jim.jeecg.imvc2.core.annotation.RequestMapping;
import com.jim.jeecg.imvc2.core.form.ActionForm;


@Controller("login")
public class LoginAction extends Action {

	@Override
	@RequestMapping(path="",form="com.jim.jeecg.imvc2.business.form.LoginForm")
	@Forward(result={"sucess","fails"},redirctUrl={"business/sucess.jsp","business/fails.jsp"})
	public String excute(ActionForm form, HttpServletRequest request,
			HttpServletResponse response) {
		// TODO Auto-generated method stub
		try { 
			request.setCharacterEncoding("utf-8");
			response.setCharacterEncoding("utf-8");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.out.println("警告：字符编码设置异常");
		}
		
		
		LoginForm loginForm=(LoginForm)form;
		
		String strName=loginForm.getName();
		String strPwd=loginForm.getPassword();
		
		if("jianbiao11".equals(strName)&&"123456".equals(strPwd))
		{
			return "sucess";
		}
		else
		{
			return "fails";
		}
	}
	

}
